﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000251 RID: 593
	public class MaterialSliderOption : MaterialControlOption
	{
		// Token: 0x06000CDF RID: 3295 RVA: 0x00067C3B File Offset: 0x00065E3B
		private void Awake()
		{
			this.slider.onValueChanged.AddListener(new UnityAction<float>(this.OnSlider));
		}

		// Token: 0x06000CE0 RID: 3296 RVA: 0x00067C5C File Offset: 0x00065E5C
		public override void ValidateOption(MaterialEntryGui newGui, List<MaterialEntryGui> newGuis)
		{
			base.ValidateOption(newGui, newGuis);
			if (this.selectedGui == null)
			{
				base.gameObject.SetActive(false);
				return;
			}
			Material material = this.selectedGui.Wrapper.Material;
			bool flag = material.HasProperty(this.propertyName);
			base.gameObject.SetActive(flag);
			if (flag)
			{
				this.slider.value = material.GetFloat(this.propertyName);
			}
		}

		// Token: 0x06000CE1 RID: 3297 RVA: 0x00067CD8 File Offset: 0x00065ED8
		private void OnSlider(float value)
		{
			if (this.selectedGuis == null)
			{
				return;
			}
			foreach (MaterialEntryGui materialEntryGui in this.selectedGuis)
			{
				if (materialEntryGui.Wrapper.Material.HasProperty(this.propertyName))
				{
					materialEntryGui.Wrapper.Material.SetFloat(this.propertyName, value);
				}
			}
		}

		// Token: 0x040011E1 RID: 4577
		[SerializeField]
		private Slider slider;

		// Token: 0x040011E2 RID: 4578
		[SerializeField]
		private string propertyName = string.Empty;
	}
}
